package com.atguigu.product.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.product.dao.SkuImagesDao;
import com.atguigu.product.entity.SkuImagesEntity;
import com.atguigu.product.service.SkuImagesService;

import javax.annotation.Resource;


@Service("skuImagesService")
public class SkuImagesServiceImpl extends ServiceImpl<SkuImagesDao, SkuImagesEntity> implements SkuImagesService {

  @Resource
  SkuImagesDao imagesDao;

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<SkuImagesEntity> page = this.page(
      new Query<SkuImagesEntity>().getPage(params),
      new QueryWrapper<SkuImagesEntity>()
    );

    return new PageUtils(page);
  }

  @Override
  public List<SkuImagesEntity> getImagesBySkuId(Long skuId) {
    List<SkuImagesEntity> images = imagesDao.selectList(new QueryWrapper<SkuImagesEntity>().eq("sku_id", skuId));
    return images;
  }

}
